/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @endpointRule = '';
  
  checkConfig(config);
  @endpoint = getEndpoint('dms-dg', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model AddDatabaseRequest {
  clientToken?: string(name='ClientToken', example='ETnLKlblzczshOTUbOCzxxxx'),
  dbDescription?: string(name='DbDescription'),
  dbName?: string(name='DbName', example='test'),
  dbPassword?: string(name='DbPassword', example='1234!2#%A***'),
  dbType?: string(name='DbType', example='MYSQL'),
  dbUserName?: string(name='DbUserName', example='test_usr'),
  gatewayId?: string(name='GatewayId', description='This parameter is required.', example='dg-8d9bqu1030m****'),
  host?: string(name='Host', description='This parameter is required.', example='127.0.XX.XX'),
  port?: int32(name='Port', description='This parameter is required.', example='3306'),
  regionId?: string(name='RegionId', description='This parameter is required.', example='cn-hangzhou'),
}

model AddDatabaseResponseBody = {
  code?: string(name='Code', example='200'),
  dbInstance?: {
    connectHost?: string(name='ConnectHost', description='连接使用的主机', example='10.0.0.1'),
    connectPort?: int32(name='ConnectPort', example='32875'),
    dbDescription?: string(name='DbDescription', description='备注信息', example='test'),
    dbType?: string(name='DbType', description='数据库类型。', example='MYSQL'),
    gatewayId?: string(name='GatewayId', description='数据库所在网关ID。

This parameter is required.', example='dg-8d9bqu1030mhk0ix'),
    gatewayName?: string(name='GatewayName', description='网关名称'),
    host?: string(name='Host', description='通过网关所在宿主机去访问数据库的地址。

This parameter is required.', example='127.0.0.1'),
    instanceId?: string(name='InstanceId', description='数据库实例ID', example='dg-db-rgfg9p4586o7y79b'),
    instanceStatus?: string(name='InstanceStatus', description='当前实例的状态', example='SUCCESS'),
    networkType?: string(name='NetworkType', description='网络类型', example='VPC'),
    nodeId?: string(name='NodeId', description='节点的ID', example='dg-node-r0SR-E90lsIRNgj6B_9m'),
    parentId?: string(name='ParentId', description='归属主账号ID', example='167xxxxxxxxxx'),
    port?: int32(name='Port', description='通过网关所在宿主机去访问数据库的端口。

This parameter is required.', example='3306'),
    regionId?: string(name='RegionId', description='所在的地域编号

This parameter is required.', example='cn-hangzhou'),
    serviceType?: string(name='ServiceType', description='服务类型', example='ECS'),
    userId?: string(name='UserId', description='用户ID', example='167xxxxxxxxxx'),
    vpcId?: string(name='VpcId', description='VpcId', example='vpc-xxxxx'),
    vpcInstanceId?: string(name='VpcInstanceId', description='VpcInstanceId', example='i-xxxxxxx'),
  }(name='DbInstance'),
  errorMsg?: string(name='ErrorMsg', example='SYSTEM_ERR'),
  requestId?: string(name='RequestId', example='A8B2EED2-70EF-51F1-8820-914F9AC9BAD2'),
  success?: boolean(name='Success', example='true'),
}

model AddDatabaseResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: AddDatabaseResponseBody(name='body'),
}

/**
 * @param request AddDatabaseRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return AddDatabaseResponse
 */
async function addDatabaseWithOptions(request: AddDatabaseRequest, runtime: Util.RuntimeOptions): AddDatabaseResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.clientToken)) {
    body['ClientToken'] = request.clientToken;
  }
  if (!Util.isUnset(request.dbDescription)) {
    body['DbDescription'] = request.dbDescription;
  }
  if (!Util.isUnset(request.dbName)) {
    body['DbName'] = request.dbName;
  }
  if (!Util.isUnset(request.dbPassword)) {
    body['DbPassword'] = request.dbPassword;
  }
  if (!Util.isUnset(request.dbType)) {
    body['DbType'] = request.dbType;
  }
  if (!Util.isUnset(request.dbUserName)) {
    body['DbUserName'] = request.dbUserName;
  }
  if (!Util.isUnset(request.gatewayId)) {
    body['GatewayId'] = request.gatewayId;
  }
  if (!Util.isUnset(request.host)) {
    body['Host'] = request.host;
  }
  if (!Util.isUnset(request.port)) {
    body['Port'] = request.port;
  }
  if (!Util.isUnset(request.regionId)) {
    body['RegionId'] = request.regionId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'AddDatabase',
    version = '2023-09-14',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @param request AddDatabaseRequest
 * @return AddDatabaseResponse
 */
async function addDatabase(request: AddDatabaseRequest): AddDatabaseResponse {
  var runtime = new Util.RuntimeOptions{};
  return addDatabaseWithOptions(request, runtime);
}

model AddDatabaseListRequest {
  clientToken?: string(name='ClientToken', example='ETnLKlblzczshOTUbOCzxxxx'),
  databaseString?: string(name='DatabaseString', description='This parameter is required.', example='[{"host":"127.0.0.1","port":"3306","gatewayId":"dg-xsdasdasdas****"}]'),
}

model AddDatabaseListResponseBody = {
  code?: string(name='Code', example='200'),
  data?: string(name='Data', example='SUCCESS'),
  errorMsg?: string(name='ErrorMsg', example='ERROR'),
  requestId?: string(name='RequestId', example='514F794F-7E30-5DAA-97C0-0B0D75DA0259'),
  success?: boolean(name='Success', example='true'),
}

model AddDatabaseListResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: AddDatabaseListResponseBody(name='body'),
}

/**
 * @param request AddDatabaseListRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return AddDatabaseListResponse
 */
async function addDatabaseListWithOptions(request: AddDatabaseListRequest, runtime: Util.RuntimeOptions): AddDatabaseListResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.clientToken)) {
    body['ClientToken'] = request.clientToken;
  }
  if (!Util.isUnset(request.databaseString)) {
    body['DatabaseString'] = request.databaseString;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'AddDatabaseList',
    version = '2023-09-14',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @param request AddDatabaseListRequest
 * @return AddDatabaseListResponse
 */
async function addDatabaseList(request: AddDatabaseListRequest): AddDatabaseListResponse {
  var runtime = new Util.RuntimeOptions{};
  return addDatabaseListWithOptions(request, runtime);
}

model CheckDGEnabledResponseBody = {
  code?: string(name='Code', example='200'),
  data?: string(name='Data', example='true'),
  errorMsg?: string(name='ErrorMsg'),
  requestId?: string(name='RequestId', example='8F29E3E9-2847-53BF-ADF0-130E3CEA5C63'),
  success?: boolean(name='Success', example='true'),
}

model CheckDGEnabledResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: CheckDGEnabledResponseBody(name='body'),
}

/**
 * @param request CheckDGEnabledRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return CheckDGEnabledResponse
 */
async function checkDGEnabledWithOptions(runtime: Util.RuntimeOptions): CheckDGEnabledResponse {
  var req = new OpenApi.OpenApiRequest{};
  var params = new OpenApi.Params{
    action = 'CheckDGEnabled',
    version = '2023-09-14',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @return CheckDGEnabledResponse
 */
async function checkDGEnabled(): CheckDGEnabledResponse {
  var runtime = new Util.RuntimeOptions{};
  return checkDGEnabledWithOptions(runtime);
}

model ConnectDatabaseRequest {
  dbName?: string(name='DbName', example='test'),
  dbPassword?: string(name='DbPassword', example='1234!2#%A****'),
  dbType?: string(name='DbType', example='MYSQL'),
  dbUserName?: string(name='DbUserName', example='test_usr'),
  gatewayId?: string(name='GatewayId', description='This parameter is required.', example='dg-58c36y906675****'),
  host?: string(name='Host', description='This parameter is required.', example='127.0.XX.XX'),
  port?: int32(name='Port', description='This parameter is required.', example='3306'),
}

model ConnectDatabaseResponseBody = {
  code?: string(name='Code', example='200'),
  data?: string(name='Data', example='OK'),
  errorMsg?: string(name='ErrorMsg', example='Gateway exception, please launch local dg first'),
  requestId?: string(name='RequestId', example='F4EFCDC5-E69C-5A6F-B170-C5379D9D6811'),
  success?: boolean(name='Success', example='true'),
}

model ConnectDatabaseResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ConnectDatabaseResponseBody(name='body'),
}

/**
 * @param request ConnectDatabaseRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return ConnectDatabaseResponse
 */
async function connectDatabaseWithOptions(request: ConnectDatabaseRequest, runtime: Util.RuntimeOptions): ConnectDatabaseResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.dbName)) {
    body['DbName'] = request.dbName;
  }
  if (!Util.isUnset(request.dbPassword)) {
    body['DbPassword'] = request.dbPassword;
  }
  if (!Util.isUnset(request.dbType)) {
    body['DbType'] = request.dbType;
  }
  if (!Util.isUnset(request.dbUserName)) {
    body['DbUserName'] = request.dbUserName;
  }
  if (!Util.isUnset(request.gatewayId)) {
    body['GatewayId'] = request.gatewayId;
  }
  if (!Util.isUnset(request.host)) {
    body['Host'] = request.host;
  }
  if (!Util.isUnset(request.port)) {
    body['Port'] = request.port;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'ConnectDatabase',
    version = '2023-09-14',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @param request ConnectDatabaseRequest
 * @return ConnectDatabaseResponse
 */
async function connectDatabase(request: ConnectDatabaseRequest): ConnectDatabaseResponse {
  var runtime = new Util.RuntimeOptions{};
  return connectDatabaseWithOptions(request, runtime);
}

model CreateGatewayRequest {
  gatewayDesc?: string(name='GatewayDesc'),
  gatewayName?: string(name='GatewayName', description='This parameter is required.'),
  regionId?: string(name='RegionId', example='cn-hangzhou'),
}

model CreateGatewayResponseBody = {
  code?: string(name='Code', example='200'),
  data?: string(name='Data', example='dg-nmz841r7b681****'),
  errorMsg?: string(name='ErrorMsg', example='Gateway exception, please launch local dg first'),
  requestId?: string(name='RequestId', example='A9A8885B-3626-592E-9149-8D2971A545AD'),
  success?: boolean(name='Success', example='true'),
}

model CreateGatewayResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: CreateGatewayResponseBody(name='body'),
}

/**
 * @summary 创建网关
 *
 * @param request CreateGatewayRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return CreateGatewayResponse
 */
async function createGatewayWithOptions(request: CreateGatewayRequest, runtime: Util.RuntimeOptions): CreateGatewayResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.gatewayDesc)) {
    body['GatewayDesc'] = request.gatewayDesc;
  }
  if (!Util.isUnset(request.gatewayName)) {
    body['GatewayName'] = request.gatewayName;
  }
  if (!Util.isUnset(request.regionId)) {
    body['RegionId'] = request.regionId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'CreateGateway',
    version = '2023-09-14',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 创建网关
 *
 * @param request CreateGatewayRequest
 * @return CreateGatewayResponse
 */
async function createGateway(request: CreateGatewayRequest): CreateGatewayResponse {
  var runtime = new Util.RuntimeOptions{};
  return createGatewayWithOptions(request, runtime);
}

model CreateGatewayVerifyCodeRequest {
  gatewayId?: string(name='GatewayId', description='This parameter is required.', example='dg-8e0j08630s08****'),
}

model CreateGatewayVerifyCodeResponseBody = {
  code?: string(name='Code', example='200'),
  data?: string(name='Data', example='0N3ufVIG43RRAs7diEoep6WHVOHPKj3a'),
  errorMsg?: string(name='ErrorMsg', example='Gateway exception, please launch local dg first'),
  requestId?: string(name='RequestId', example='C9ADD2AA-27E3-5D62-A676-092EDC5303C1'),
  success?: boolean(name='Success', example='true'),
}

model CreateGatewayVerifyCodeResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: CreateGatewayVerifyCodeResponseBody(name='body'),
}

/**
 * @summary 创建网关的随机验证码
 *
 * @param request CreateGatewayVerifyCodeRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return CreateGatewayVerifyCodeResponse
 */
async function createGatewayVerifyCodeWithOptions(request: CreateGatewayVerifyCodeRequest, runtime: Util.RuntimeOptions): CreateGatewayVerifyCodeResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.gatewayId)) {
    body['GatewayId'] = request.gatewayId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'CreateGatewayVerifyCode',
    version = '2023-09-14',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 创建网关的随机验证码
 *
 * @param request CreateGatewayVerifyCodeRequest
 * @return CreateGatewayVerifyCodeResponse
 */
async function createGatewayVerifyCode(request: CreateGatewayVerifyCodeRequest): CreateGatewayVerifyCodeResponse {
  var runtime = new Util.RuntimeOptions{};
  return createGatewayVerifyCodeWithOptions(request, runtime);
}

model DeleteDatabaseRequest {
  instanceId?: string(name='InstanceId', description='This parameter is required.', example='db-22h1qa9d452f****'),
}

model DeleteDatabaseResponseBody = {
  code?: string(name='Code', example='200'),
  data?: string(name='Data', example='SUCCESS'),
  errorMsg?: string(name='ErrorMsg', example='Gateway exception, please launch local dg first'),
  requestId?: string(name='RequestId', example='B9FB545B-03E3-5AE3-9D9E-2FE26EE2C48F'),
  success?: boolean(name='Success', example='true'),
}

model DeleteDatabaseResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DeleteDatabaseResponseBody(name='body'),
}

/**
 * @param request DeleteDatabaseRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return DeleteDatabaseResponse
 */
async function deleteDatabaseWithOptions(request: DeleteDatabaseRequest, runtime: Util.RuntimeOptions): DeleteDatabaseResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.instanceId)) {
    body['InstanceId'] = request.instanceId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'DeleteDatabase',
    version = '2023-09-14',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @param request DeleteDatabaseRequest
 * @return DeleteDatabaseResponse
 */
async function deleteDatabase(request: DeleteDatabaseRequest): DeleteDatabaseResponse {
  var runtime = new Util.RuntimeOptions{};
  return deleteDatabaseWithOptions(request, runtime);
}

model DeleteGatewayRequest {
  gatewayId?: string(name='GatewayId', description='This parameter is required.', example='dg-nmz841r7b681****'),
}

model DeleteGatewayResponseBody = {
  code?: string(name='Code', example='200'),
  data?: string(name='Data', example='SUCCESS'),
  errorMsg?: string(name='ErrorMsg', example='Gateway exception, please launch local dg first'),
  requestId?: string(name='RequestId', example='8F29E3E9-2847-53BF-ADF0-130E3CEA5C63'),
  success?: boolean(name='Success', example='true'),
}

model DeleteGatewayResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DeleteGatewayResponseBody(name='body'),
}

/**
 * @summary 删除网关
 *
 * @param request DeleteGatewayRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return DeleteGatewayResponse
 */
async function deleteGatewayWithOptions(request: DeleteGatewayRequest, runtime: Util.RuntimeOptions): DeleteGatewayResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.gatewayId)) {
    body['GatewayId'] = request.gatewayId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'DeleteGateway',
    version = '2023-09-14',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 删除网关
 *
 * @param request DeleteGatewayRequest
 * @return DeleteGatewayResponse
 */
async function deleteGateway(request: DeleteGatewayRequest): DeleteGatewayResponse {
  var runtime = new Util.RuntimeOptions{};
  return deleteGatewayWithOptions(request, runtime);
}

model DeleteGatewayInstanceRequest {
  gatewayId?: string(name='GatewayId', description='This parameter is required.', example='dg-nmz841r7b681****'),
  gatewayInstanceId?: string(name='GatewayInstanceId', description='This parameter is required.', example='dg-node-QeH6VfT8GRnPrYWX****'),
  regionId?: string(name='RegionId', description='This parameter is required.', example='cn-hangzhou'),
}

model DeleteGatewayInstanceResponseBody = {
  code?: string(name='Code', example='200'),
  data?: string(name='Data', example='SUCCESS'),
  errorMsg?: string(name='ErrorMsg', example='Gateway exception, please launch local dg first'),
  requestId?: string(name='RequestId', example='8F29E3E9-2847-53BF-ADF0-130E3CEA5C63'),
  success?: boolean(name='Success', example='true'),
}

model DeleteGatewayInstanceResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DeleteGatewayInstanceResponseBody(name='body'),
}

/**
 * @param request DeleteGatewayInstanceRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return DeleteGatewayInstanceResponse
 */
async function deleteGatewayInstanceWithOptions(request: DeleteGatewayInstanceRequest, runtime: Util.RuntimeOptions): DeleteGatewayInstanceResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.gatewayId)) {
    body['GatewayId'] = request.gatewayId;
  }
  if (!Util.isUnset(request.gatewayInstanceId)) {
    body['GatewayInstanceId'] = request.gatewayInstanceId;
  }
  if (!Util.isUnset(request.regionId)) {
    body['RegionId'] = request.regionId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'DeleteGatewayInstance',
    version = '2023-09-14',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @param request DeleteGatewayInstanceRequest
 * @return DeleteGatewayInstanceResponse
 */
async function deleteGatewayInstance(request: DeleteGatewayInstanceRequest): DeleteGatewayInstanceResponse {
  var runtime = new Util.RuntimeOptions{};
  return deleteGatewayInstanceWithOptions(request, runtime);
}

model DescribeRegionsRequest {
  regionId?: string(name='RegionId', example='cn-hangzhou'),
}

model DescribeRegionsResponseBody = {
  code?: string(name='Code', example='200'),
  errorMsg?: string(name='ErrorMsg', example='Gateway exception, please launch local dg first'),
  regions?: {
    region?: [ 
    {
      localName?: string(name='LocalName'),
      regionEndpoint?: string(name='RegionEndpoint', example='dg.cn-hangzhou.aliyuncs.com'),
      regionId?: string(name='RegionId', example='cn-hangzhou'),
    }
  ](name='Region')
  }(name='Regions'),
  requestId?: string(name='RequestId', example='B0557F7A-62C3-50DC-9E09-77CAE658F776'),
  success?: boolean(name='Success', example='true'),
}

model DescribeRegionsResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DescribeRegionsResponseBody(name='body'),
}

/**
 * @param request DescribeRegionsRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return DescribeRegionsResponse
 */
async function describeRegionsWithOptions(request: DescribeRegionsRequest, runtime: Util.RuntimeOptions): DescribeRegionsResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.regionId)) {
    body['RegionId'] = request.regionId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'DescribeRegions',
    version = '2023-09-14',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @param request DescribeRegionsRequest
 * @return DescribeRegionsResponse
 */
async function describeRegions(request: DescribeRegionsRequest): DescribeRegionsResponse {
  var runtime = new Util.RuntimeOptions{};
  return describeRegionsWithOptions(request, runtime);
}

model DownloadGatewayProgramRequest {
  dgVersion?: string(name='DgVersion', example='3.0'),
  userOS?: string(name='UserOS', example='LINUX'),
}

model DownloadGatewayProgramResponseBody = {
  code?: string(name='Code', example='200'),
  data?: string(name='Data', example='https://dg-prod-cn-hangzhou.oss-cn-hangzhou.aliyuncs.com/dg3-pkgs/DBGateway_linux?Expires=170833****&OSSAccessKeyId=LTAIfHvNGC8y****&Signature=wa8KqWuyZdB0hwx%2BKvbgZeSTW****'),
  errorMsg?: string(name='ErrorMsg', example='Gateway exception, please launch local dg first'),
  requestId?: string(name='RequestId', example='15D856B8-A95C-5DA5-B0FC-67246286EA7F'),
  success?: boolean(name='Success', example='true'),
}

model DownloadGatewayProgramResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DownloadGatewayProgramResponseBody(name='body'),
}

/**
 * @param request DownloadGatewayProgramRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return DownloadGatewayProgramResponse
 */
async function downloadGatewayProgramWithOptions(request: DownloadGatewayProgramRequest, runtime: Util.RuntimeOptions): DownloadGatewayProgramResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.dgVersion)) {
    body['DgVersion'] = request.dgVersion;
  }
  if (!Util.isUnset(request.userOS)) {
    body['UserOS'] = request.userOS;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'DownloadGatewayProgram',
    version = '2023-09-14',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @param request DownloadGatewayProgramRequest
 * @return DownloadGatewayProgramResponse
 */
async function downloadGatewayProgram(request: DownloadGatewayProgramRequest): DownloadGatewayProgramResponse {
  var runtime = new Util.RuntimeOptions{};
  return downloadGatewayProgramWithOptions(request, runtime);
}

model FindUserGatewayByIdRequest {
  gatewayId?: string(name='GatewayId', description='This parameter is required.', example='dg-nmz841r7b681****'),
}

model FindUserGatewayByIdResponseBody = {
  code?: string(name='Code', example='200'),
  errorMsg?: string(name='ErrorMsg', example='Gateway exception, please launch local dg first'),
  gateway?: {
    creatorId?: string(name='CreatorId', example='test_user'),
    dgVersion?: string(name='DgVersion', example='3.0'),
    exceptionMsg?: string(name='ExceptionMsg', example='Gateway exception, please launch local dg first'),
    gatewayDesc?: string(name='GatewayDesc', description='网关的描述'),
    gatewayId?: string(name='GatewayId', description='网关的编号', example='dg-pv33g51gw69h****'),
    gatewayName?: string(name='GatewayName', description='网关的名称

This parameter is required.'),
    numOfExceptionInstance?: int32(name='NumOfExceptionInstance', example='3'),
    numOfRunningInstance?: int32(name='NumOfRunningInstance', example='3'),
    regionId?: string(name='RegionId', description='地域的编号', example='cn-hangzhou'),
    status?: string(name='Status', description='网关的状态', example='RUNNING'),
    userId?: string(name='UserId', description='用户的编号', example='100****'),
  }(name='Gateway'),
  requestId?: string(name='RequestId', example='41FC4DFE-EA8A-5A56-A16C-F607C3409C79'),
  success?: boolean(name='Success', example='true'),
}

model FindUserGatewayByIdResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: FindUserGatewayByIdResponseBody(name='body'),
}

/**
 * @summary 根据GatewayId查找网关详情
 *
 * @param request FindUserGatewayByIdRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return FindUserGatewayByIdResponse
 */
async function findUserGatewayByIdWithOptions(request: FindUserGatewayByIdRequest, runtime: Util.RuntimeOptions): FindUserGatewayByIdResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.gatewayId)) {
    body['GatewayId'] = request.gatewayId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'FindUserGatewayById',
    version = '2023-09-14',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 根据GatewayId查找网关详情
 *
 * @param request FindUserGatewayByIdRequest
 * @return FindUserGatewayByIdResponse
 */
async function findUserGatewayById(request: FindUserGatewayByIdRequest): FindUserGatewayByIdResponse {
  var runtime = new Util.RuntimeOptions{};
  return findUserGatewayByIdWithOptions(request, runtime);
}

model GetUserDatabasesRequest {
  dbType?: string(name='DbType', example='MYSQL'),
  gatewayId?: string(name='GatewayId', example='dg-nmz841r7b681****'),
  host?: string(name='Host', example='127.0.XX.XX'),
  instanceId?: string(name='InstanceId', example='db-22h1qa9d452f****'),
  pageNumber?: string(name='PageNumber', example='1'),
  pageSize?: string(name='PageSize', example='10'),
  port?: int32(name='Port', example='3306'),
  regionId?: string(name='RegionId', example='cn-hangzhou'),
  searchKey?: string(name='SearchKey'),
}

model GetUserDatabasesResponseBody = {
  code?: string(name='Code', example='200'),
  count?: int32(name='Count', example='100'),
  dbInstanceList?: {
    dbInstance?: [ 
    {
      connectHost?: string(name='ConnectHost', description='连接使用的主机', example='10.0.0.0'),
      connectPort?: int32(name='ConnectPort', example='10001'),
      dbDescription?: string(name='DbDescription', description='备注信息'),
      dbType?: string(name='DbType', description='数据库类型。', example='MYSQL'),
      gatewayId?: string(name='GatewayId', description='数据库所在网关ID。

This parameter is required.', example='dg-pil582nbfe6p****'),
      gatewayName?: string(name='GatewayName', description='网关名称'),
      gmtCreate?: long(name='GmtCreate', description='创建时间', example='2023-05-03 00:00:00'),
      host?: string(name='Host', description='通过网关所在宿主机去访问数据库的地址。

This parameter is required.', example='127.0.XX.XX'),
      instanceId?: string(name='InstanceId', description='数据库实例ID', example='db-22h1qa9d452f****'),
      instanceStatus?: string(name='InstanceStatus', description='当前实例的状态', example='SUCCESS'),
      networkType?: string(name='NetworkType', description='网络类型', example='VPC'),
      nodeId?: string(name='NodeId', description='节点的ID', example='dg-node-xxxxx'),
      parentId?: string(name='ParentId', description='归属主账号ID', example='100XXXXX'),
      port?: int32(name='Port', description='通过网关所在宿主机去访问数据库的端口。

This parameter is required.', example='3306'),
      regionId?: string(name='RegionId', description='所在的地域编号

This parameter is required.', example='cn-hangzhou'),
      serviceType?: string(name='ServiceType', description='服务类型', example='ECS'),
      userId?: string(name='UserId', description='用户ID', example='100XXXXX'),
      vpcId?: string(name='VpcId', description='VpcId', example='vpc-bp1alpkpdb8fh3avx****'),
      vpcInstanceId?: string(name='VpcInstanceId', description='VpcInstanceId', example='i-xxxxxxxxxx'),
    }
  ](name='DbInstance')
  }(name='DbInstanceList'),
  errorMsg?: string(name='ErrorMsg', example='Gateway exception, please launch local dg first'),
  requestId?: string(name='RequestId', example='514F794F-7E30-5DAA-97C0-0B0D75DA0259'),
  success?: string(name='Success', example='true'),
}

model GetUserDatabasesResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetUserDatabasesResponseBody(name='body'),
}

/**
 * @param request GetUserDatabasesRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetUserDatabasesResponse
 */
async function getUserDatabasesWithOptions(request: GetUserDatabasesRequest, runtime: Util.RuntimeOptions): GetUserDatabasesResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.dbType)) {
    body['DbType'] = request.dbType;
  }
  if (!Util.isUnset(request.gatewayId)) {
    body['GatewayId'] = request.gatewayId;
  }
  if (!Util.isUnset(request.host)) {
    body['Host'] = request.host;
  }
  if (!Util.isUnset(request.instanceId)) {
    body['InstanceId'] = request.instanceId;
  }
  if (!Util.isUnset(request.pageNumber)) {
    body['PageNumber'] = request.pageNumber;
  }
  if (!Util.isUnset(request.pageSize)) {
    body['PageSize'] = request.pageSize;
  }
  if (!Util.isUnset(request.port)) {
    body['Port'] = request.port;
  }
  if (!Util.isUnset(request.regionId)) {
    body['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.searchKey)) {
    body['SearchKey'] = request.searchKey;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'GetUserDatabases',
    version = '2023-09-14',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @param request GetUserDatabasesRequest
 * @return GetUserDatabasesResponse
 */
async function getUserDatabases(request: GetUserDatabasesRequest): GetUserDatabasesResponse {
  var runtime = new Util.RuntimeOptions{};
  return getUserDatabasesWithOptions(request, runtime);
}

model GetUserGatewayInstancesRequest {
  gatewayId?: string(name='GatewayId', description='This parameter is required.', example='dg-nmz841r7b681****'),
}

model GetUserGatewayInstancesResponseBody = {
  code?: string(name='Code', example='200'),
  errorMsg?: string(name='ErrorMsg', example='Gateway exception, please launch local dg first'),
  gatewayInstanceList?: [ 
    {
      connectEndpointType?: string(name='ConnectEndpointType', description='连接类型', example='internet'),
      currentDaemonVersion?: string(name='CurrentDaemonVersion', description='进程的版本号', example='3.0'),
      currentVersion?: string(name='CurrentVersion', description='版本号', example='3.0'),
      endPoint?: string(name='EndPoint', description='端点地址', example='127.0.XX.XX'),
      gatewayId?: string(name='GatewayId', description='网关ID', example='dg-159t17m19ps0****'),
      gatewayInstanceId?: string(name='GatewayInstanceId', description='代表资源一级ID的资源属性字段', example='dg-node-wJOb0tO-gaaWFCug****'),
      gatewayInstanceStatus?: string(name='GatewayInstanceStatus', example='STOPPED'),
      lastUpdateTime?: long(name='LastUpdateTime', description='上次更新时间戳', example='1699330233000'),
      localIP?: string(name='LocalIP', description='本地IP地址', example='127.0.XX.XX'),
      message?: string(name='Message', description='提示信息', example='SUCCESS'),
      outputIP?: string(name='OutputIP', description='主机', example='127.0.0.1'),
      regionId?: string(name='RegionId', description='代表region的资源属性字段', example='cn-hangzhou'),
    }
  ](name='GatewayInstanceList'),
  requestId?: string(name='RequestId', example='514F794F-7E30-5DAA-97C0-0B0D75DA0259'),
  success?: boolean(name='Success', example='true'),
}

model GetUserGatewayInstancesResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetUserGatewayInstancesResponseBody(name='body'),
}

/**
 * @param request GetUserGatewayInstancesRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetUserGatewayInstancesResponse
 */
async function getUserGatewayInstancesWithOptions(request: GetUserGatewayInstancesRequest, runtime: Util.RuntimeOptions): GetUserGatewayInstancesResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.gatewayId)) {
    body['GatewayId'] = request.gatewayId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'GetUserGatewayInstances',
    version = '2023-09-14',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @param request GetUserGatewayInstancesRequest
 * @return GetUserGatewayInstancesResponse
 */
async function getUserGatewayInstances(request: GetUserGatewayInstancesRequest): GetUserGatewayInstancesResponse {
  var runtime = new Util.RuntimeOptions{};
  return getUserGatewayInstancesWithOptions(request, runtime);
}

model GetUserGatewaysRequest {
  pageNumber?: int32(name='PageNumber', example='1'),
  pageSize?: int32(name='PageSize', example='100'),
  regionId?: string(name='RegionId', example='cn-hangzhou'),
  searchKey?: string(name='SearchKey'),
}

model GetUserGatewaysResponseBody = {
  code?: string(name='Code', example='200'),
  count?: int32(name='Count', example='20'),
  errorMsg?: string(name='ErrorMsg', example='Gateway exception, please launch local dg first'),
  gatewayList?: {
    gateway?: [ 
    {
      creatorId?: string(name='CreatorId', description='创建用户id', example='100****'),
      dgVersion?: string(name='DgVersion', description='网关版本', example='3.0'),
      exceptionMsg?: string(name='ExceptionMsg', description='网关异常信息', example='exception'),
      gatewayDesc?: string(name='GatewayDesc', description='网关的描述'),
      gatewayId?: string(name='GatewayId', description='网关的编号', example='dg-lch384wg5701****'),
      gatewayName?: string(name='GatewayName', description='网关的名称

This parameter is required.'),
      numOfExceptionInstance?: int32(name='NumOfExceptionInstance', description='异常实例数量', example='3'),
      numOfRunningInstance?: int32(name='NumOfRunningInstance', description='运行中实例数量', example='3'),
      regionId?: string(name='RegionId', description='地域的编号', example='cn-hangzhou'),
      status?: string(name='Status', description='网关的状态', example='RUNNING'),
      userId?: string(name='UserId', description='用户的编号', example='100****'),
    }
  ](name='Gateway')
  }(name='GatewayList'),
  requestId?: string(name='RequestId', example='41FC4DFE-EA8A-5A56-A16C-F607C3409C79'),
  success?: boolean(name='Success', example='true'),
}

model GetUserGatewaysResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetUserGatewaysResponseBody(name='body'),
}

/**
 * @summary 获取用户DG网关列表
 *
 * @param request GetUserGatewaysRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetUserGatewaysResponse
 */
async function getUserGatewaysWithOptions(request: GetUserGatewaysRequest, runtime: Util.RuntimeOptions): GetUserGatewaysResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.pageNumber)) {
    body['PageNumber'] = request.pageNumber;
  }
  if (!Util.isUnset(request.pageSize)) {
    body['PageSize'] = request.pageSize;
  }
  if (!Util.isUnset(request.regionId)) {
    body['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.searchKey)) {
    body['SearchKey'] = request.searchKey;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'GetUserGateways',
    version = '2023-09-14',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 获取用户DG网关列表
 *
 * @param request GetUserGatewaysRequest
 * @return GetUserGatewaysResponse
 */
async function getUserGateways(request: GetUserGatewaysRequest): GetUserGatewaysResponse {
  var runtime = new Util.RuntimeOptions{};
  return getUserGatewaysWithOptions(request, runtime);
}

model ListDatabaseAccessPointRequest {
  dbInstanceId?: string(name='DbInstanceId', example='dg-db-n2a285spnpy3****'),
  gatewayId?: string(name='GatewayId', example='dg-nmz841r7b681****'),
  host?: string(name='Host', example='127.0.XX.XX'),
  pageNumber?: string(name='PageNumber', example='1'),
  pageSize?: string(name='PageSize', example='10'),
  port?: int32(name='Port', example='3306'),
  regionId?: string(name='RegionId', example='cn-hangzhou'),
  searchKey?: string(name='SearchKey'),
  vpcId?: string(name='VpcId', example='vpc-wz9c473cmu2gg7i7l****'),
}

model ListDatabaseAccessPointResponseBody = {
  code?: string(name='Code', example='200'),
  count?: int32(name='Count', example='1'),
  dbInstanceAccessPointList?: [ 
    {
      accessAddr?: string(name='AccessAddr', example='10.0.0.0'),
      accessPort?: int32(name='AccessPort', example='33306'),
      dbInstanceId?: string(name='DbInstanceId', example='dg-db-n2a285spnpy3****'),
      gmtCreate?: long(name='GmtCreate', example='2023-03-09 14:20:04.0'),
      gmtModified?: long(name='GmtModified', example='2023-03-09 14:20:04.0'),
      routerId?: string(name='RouterId', example='dg-nmz841r7b681****'),
      vpcAzoneId?: string(name='VpcAzoneId', example='cn-hangzhou-j'),
      vpcId?: string(name='VpcId', example='vpc-2ze0612ts436tn0sh****'),
      vswitchId?: string(name='VswitchId', example='vsw-8vbgi74rgel72rax4****'),
    }
  ](name='DbInstanceAccessPointList'),
  errorMsg?: string(name='ErrorMsg', example='Gateway exception, please launch local dg first'),
  requestId?: string(name='RequestId', example='C9ADD2AA-27E3-5D62-A676-092EDC5303C1'),
  success?: string(name='Success', example='true'),
}

model ListDatabaseAccessPointResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ListDatabaseAccessPointResponseBody(name='body'),
}

/**
 * @param request ListDatabaseAccessPointRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return ListDatabaseAccessPointResponse
 */
async function listDatabaseAccessPointWithOptions(request: ListDatabaseAccessPointRequest, runtime: Util.RuntimeOptions): ListDatabaseAccessPointResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.dbInstanceId)) {
    body['DbInstanceId'] = request.dbInstanceId;
  }
  if (!Util.isUnset(request.gatewayId)) {
    body['GatewayId'] = request.gatewayId;
  }
  if (!Util.isUnset(request.host)) {
    body['Host'] = request.host;
  }
  if (!Util.isUnset(request.pageNumber)) {
    body['PageNumber'] = request.pageNumber;
  }
  if (!Util.isUnset(request.pageSize)) {
    body['PageSize'] = request.pageSize;
  }
  if (!Util.isUnset(request.port)) {
    body['Port'] = request.port;
  }
  if (!Util.isUnset(request.regionId)) {
    body['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.searchKey)) {
    body['SearchKey'] = request.searchKey;
  }
  if (!Util.isUnset(request.vpcId)) {
    body['VpcId'] = request.vpcId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'ListDatabaseAccessPoint',
    version = '2023-09-14',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @param request ListDatabaseAccessPointRequest
 * @return ListDatabaseAccessPointResponse
 */
async function listDatabaseAccessPoint(request: ListDatabaseAccessPointRequest): ListDatabaseAccessPointResponse {
  var runtime = new Util.RuntimeOptions{};
  return listDatabaseAccessPointWithOptions(request, runtime);
}

model ModifyDatabaseRequest {
  dbDescription?: string(name='DbDescription'),
  dbName?: string(name='DbName', example='test'),
  dbPassword?: string(name='DbPassword', example='817130****'),
  dbType?: string(name='DbType', example='MYSQL'),
  dbUserName?: string(name='DbUserName', example='test'),
  host?: string(name='Host', description='This parameter is required.', example='127.0.XX.XX'),
  instanceId?: string(name='InstanceId', description='This parameter is required.', example='dg-db-n2a285spnpy3****'),
  port?: int32(name='Port', description='This parameter is required.', example='3306'),
}

model ModifyDatabaseResponseBody = {
  code?: string(name='Code', example='200'),
  data?: string(name='Data', example='SUCCESS'),
  errorMsg?: string(name='ErrorMsg', example='Gateway exception, please launch local dg first'),
  requestId?: string(name='RequestId', example='8F29E3E9-2847-53BF-ADF0-130E3CEA5C63'),
  success?: boolean(name='Success', example='true'),
}

model ModifyDatabaseResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ModifyDatabaseResponseBody(name='body'),
}

/**
 * @param request ModifyDatabaseRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return ModifyDatabaseResponse
 */
async function modifyDatabaseWithOptions(request: ModifyDatabaseRequest, runtime: Util.RuntimeOptions): ModifyDatabaseResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.dbDescription)) {
    body['DbDescription'] = request.dbDescription;
  }
  if (!Util.isUnset(request.dbName)) {
    body['DbName'] = request.dbName;
  }
  if (!Util.isUnset(request.dbPassword)) {
    body['DbPassword'] = request.dbPassword;
  }
  if (!Util.isUnset(request.dbType)) {
    body['DbType'] = request.dbType;
  }
  if (!Util.isUnset(request.dbUserName)) {
    body['DbUserName'] = request.dbUserName;
  }
  if (!Util.isUnset(request.host)) {
    body['Host'] = request.host;
  }
  if (!Util.isUnset(request.instanceId)) {
    body['InstanceId'] = request.instanceId;
  }
  if (!Util.isUnset(request.port)) {
    body['Port'] = request.port;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'ModifyDatabase',
    version = '2023-09-14',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @param request ModifyDatabaseRequest
 * @return ModifyDatabaseResponse
 */
async function modifyDatabase(request: ModifyDatabaseRequest): ModifyDatabaseResponse {
  var runtime = new Util.RuntimeOptions{};
  return modifyDatabaseWithOptions(request, runtime);
}

model ModifyGatewayRequest {
  gatewayDesc?: string(name='GatewayDesc'),
  gatewayId?: string(name='GatewayId', description='This parameter is required.', example='dg-nmz841r7b681****'),
  gatewayName?: string(name='GatewayName', description='This parameter is required.'),
}

model ModifyGatewayResponseBody = {
  code?: string(name='Code', example='200'),
  data?: string(name='Data', example='SUCCESS'),
  errorMsg?: string(name='ErrorMsg', example='Gateway exception, please launch local dg first'),
  requestId?: string(name='RequestId', example='18071187-5EA1-5DD4-AAD9-F27C5713CD1C'),
  success?: boolean(name='Success', example='true'),
}

model ModifyGatewayResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ModifyGatewayResponseBody(name='body'),
}

/**
 * @summary 修改网关信息
 *
 * @param request ModifyGatewayRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return ModifyGatewayResponse
 */
async function modifyGatewayWithOptions(request: ModifyGatewayRequest, runtime: Util.RuntimeOptions): ModifyGatewayResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.gatewayDesc)) {
    body['GatewayDesc'] = request.gatewayDesc;
  }
  if (!Util.isUnset(request.gatewayId)) {
    body['GatewayId'] = request.gatewayId;
  }
  if (!Util.isUnset(request.gatewayName)) {
    body['GatewayName'] = request.gatewayName;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'ModifyGateway',
    version = '2023-09-14',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 修改网关信息
 *
 * @param request ModifyGatewayRequest
 * @return ModifyGatewayResponse
 */
async function modifyGateway(request: ModifyGatewayRequest): ModifyGatewayResponse {
  var runtime = new Util.RuntimeOptions{};
  return modifyGatewayWithOptions(request, runtime);
}

model RetryDatabaseRequest {
  clientToken?: string(name='ClientToken', example='XXXXX'),
  dbDescription?: string(name='DbDescription'),
  dbName?: string(name='DbName', example='test'),
  dbPassword?: string(name='DbPassword', example='HongRui****'),
  dbType?: string(name='DbType', example='MYSQL'),
  dbUserName?: string(name='DbUserName', example='test'),
  gatewayId?: string(name='GatewayId', description='This parameter is required.', example='dg-nmz841r7b681****'),
  host?: string(name='Host', description='This parameter is required.', example='127.0.XX.XX'),
  port?: int32(name='Port', description='This parameter is required.', example='3306'),
  regionId?: string(name='RegionId', description='This parameter is required.', example='cn-hangzhou'),
}

model RetryDatabaseResponseBody = {
  code?: string(name='Code', example='200'),
  data?: string(name='Data', example='SUCCESS'),
  errorMsg?: string(name='ErrorMsg', example='Gateway exception, please launch local dg first'),
  requestId?: string(name='RequestId', example='19EDB8E2-FCE6-5797-91F4-80F832C90371'),
  success?: boolean(name='Success', example='true'),
}

model RetryDatabaseResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: RetryDatabaseResponseBody(name='body'),
}

/**
 * @param request RetryDatabaseRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return RetryDatabaseResponse
 */
async function retryDatabaseWithOptions(request: RetryDatabaseRequest, runtime: Util.RuntimeOptions): RetryDatabaseResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.clientToken)) {
    body['ClientToken'] = request.clientToken;
  }
  if (!Util.isUnset(request.dbDescription)) {
    body['DbDescription'] = request.dbDescription;
  }
  if (!Util.isUnset(request.dbName)) {
    body['DbName'] = request.dbName;
  }
  if (!Util.isUnset(request.dbPassword)) {
    body['DbPassword'] = request.dbPassword;
  }
  if (!Util.isUnset(request.dbType)) {
    body['DbType'] = request.dbType;
  }
  if (!Util.isUnset(request.dbUserName)) {
    body['DbUserName'] = request.dbUserName;
  }
  if (!Util.isUnset(request.gatewayId)) {
    body['GatewayId'] = request.gatewayId;
  }
  if (!Util.isUnset(request.host)) {
    body['Host'] = request.host;
  }
  if (!Util.isUnset(request.port)) {
    body['Port'] = request.port;
  }
  if (!Util.isUnset(request.regionId)) {
    body['RegionId'] = request.regionId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'RetryDatabase',
    version = '2023-09-14',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @param request RetryDatabaseRequest
 * @return RetryDatabaseResponse
 */
async function retryDatabase(request: RetryDatabaseRequest): RetryDatabaseResponse {
  var runtime = new Util.RuntimeOptions{};
  return retryDatabaseWithOptions(request, runtime);
}

model StopGatewayRequest {
  gatewayId?: string(name='GatewayId', description='This parameter is required.', example='dg-nmz841r7b681****'),
  gatewayInstanceId?: string(name='GatewayInstanceId', example='dg-node-hvsGB7qVCaaW****-v-0'),
}

model StopGatewayResponseBody = {
  code?: string(name='Code', example='200'),
  data?: string(name='Data', example='SUCCESS'),
  errorMsg?: string(name='ErrorMsg', example='Gateway exception, please launch local dg first'),
  requestId?: string(name='RequestId', example='DE3CC21B-E317-5ED7-A212-A62517EA0022'),
  success?: boolean(name='Success', example='true'),
}

model StopGatewayResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: StopGatewayResponseBody(name='body'),
}

/**
 * @summary 停止网关实例
 *
 * @param request StopGatewayRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return StopGatewayResponse
 */
async function stopGatewayWithOptions(request: StopGatewayRequest, runtime: Util.RuntimeOptions): StopGatewayResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.gatewayId)) {
    body['GatewayId'] = request.gatewayId;
  }
  if (!Util.isUnset(request.gatewayInstanceId)) {
    body['GatewayInstanceId'] = request.gatewayInstanceId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'StopGateway',
    version = '2023-09-14',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 停止网关实例
 *
 * @param request StopGatewayRequest
 * @return StopGatewayResponse
 */
async function stopGateway(request: StopGatewayRequest): StopGatewayResponse {
  var runtime = new Util.RuntimeOptions{};
  return stopGatewayWithOptions(request, runtime);
}

